﻿#include"head.h"

class Logestic {
	Matrix<LD> hiden;
	LD biet;

	Logestic(size_t weightNum, size_t layer):biet(0){
		hiden(layer, weightNum);
	}

	void setRandom() {
		hiden.for_each(1);
		LD* temp = hiden.for_each();
		while (temp) {
			*temp = getrandom();
			temp = hiden.for_each();
		}
		hiden.for_each(1);
	}

	LD forward(std::vector<LD>& var) {
		LD result = 0;
		Matrix<LD> temp(var);

		temp.dot(hiden.T_f()) + biet;

		temp.for_each(1);
		LD* iter = temp.for_each();
		while (iter) {
			result += sigmoid(*iter);
		}
		temp.for_each(1);
		return result;
	}

	void train(Matrix<LD>& var, std::vector<LD>& actual, LD learning_rate = 0.01, size_t repeat = 10) {
		for (size_t rp = 0; rp < repeat; rp++) {
			var.each_line(1);
			std::vector<LD>* temp = var.each_line();
			std::vector<LD> pred_per;
			while (temp) {
				pred_per.push_back(this->forward(*temp));
			}
			LD loss=calLoss(pred_per, actual);

		}
	}
};